﻿<UserControl x:Class="CodeCounsel.SharePoint.RibbonDesigner.View.Button" 
                       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                       xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                       xmlns:v="clr-namespace:CodeCounsel.SharePoint.RibbonDesigner.View"
                       xmlns:t="clr-namespace:CodeCounsel.SharePoint.RibbonDesigner.View.TypeConverters"
                       Focusable="False"
                       mc:Ignorable="d">
    <UserControl.Resources>
        <t:ResourceConverter x:Key="resourceConverter" />
    </UserControl.Resources>
    <UserControl.Style>
        <Style TargetType="{x:Type UserControl}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding DisplayMode}" Value="Large">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <StackPanel>
                                    <Image HorizontalAlignment="Center" Source="{Binding LargeImage}">
                                        <Image.ToolTip>
                                            <ToolTip>
                                                <TextBlock Text="{Binding Source}" />
                                            </ToolTip>
                                        </Image.ToolTip>
                                    </Image>
                                    <TextBlock Text="{Binding Path=Title, Converter={StaticResource resourceConverter},  TargetNullValue=(No Value)}" HorizontalAlignment="Center" />
                                </StackPanel>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </DataTrigger>
                <DataTrigger Binding="{Binding DisplayMode}" Value="Medium">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="{Binding SmallImage}" ToolTip="{Binding Source}"/>
                                    <TextBlock Text="{Binding Title, Converter={StaticResource resourceConverter}}" />
                                </StackPanel>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </DataTrigger>
                <DataTrigger Binding="{Binding DisplayMode}" Value="Small">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <Image Source="{Binding SmallImage}" ToolTip="{Binding Source}"/>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </UserControl.Style>
</UserControl>
